package WaiBao;

import java.util.Arrays;

public class BaiXinRong {
    public static void main(String[] args) {
        String[] name = {"赵匡胤(班长)", "佟大为(体育委员)", "小李(学习委员)", "张凯丽(文艺委员)", "李有为", "晁盖", "雷强", "李泽宇", "王志豪", "李天东", "张大炮", "张青",
                "赵富贵", "李韬", "张才贵", "潇潇", "宋正庭", "李不", "王德发", "倪大红", "张艺谋", "李冰冰", "张水水", "金荣", "李道", "金庸", "王晨", "周星驰",
                "肖战", "白鑫荣(学生)"};//考生本人: 白鑫荣(学生)
        int[] age = {19, 21, 20, 19, 18, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 19};//最后一位：考生年龄:19
        double[] C1 = {67, 72, 84, 90, 79, 69, 78, 89, 80, 80, 91, 87, 85, 89, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 95};
        double[] C2 = {75, 85, 99, 76, 78, 77, 78, 69, 90, 70, 90, 77, 66, 95, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 95};
        double[] C3 = {84, 76, 84, 85, 77, 66, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 94};

        double Fun1;//代表每个学生的总分
        double Gun2;//代表每个学生的平均分

//        for (int i = 0; i < name.length; i++) {
//            System.out.println("姓名:"+name[i]+" "+"年龄:"+age[i]);
//        }
//        for (int i = 0; i < 30; i++) {
//            Fun1 = C1[i] + C2[i] + C3[i];
//            Gun2 = (Fun1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + Fun1);
//            System.out.println(name[i] + "的平均分为:" + Gun2);
//        }


//        double S = 0, K = 0;
//        double[] Arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            S = C1[i] + C2[i] + C3[i];
//            K= (S * 1.0) / 3;
//            Arr[i] = K;
//        }
//
//        for (int i = 0; i < Arr.length - 1; i++) {
//            for (int j = 0; j < Arr.length - i - 1; j++) {
//                if (Arr[j] < Arr[j + 1]) {
//                    double tep = Arr[j];
//                    Arr[j] = Arr[j + 1];
//                    Arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Arr[i]);
//        }


        double X1 = 0, X2 = 0, X3 = 0;//计算每门课的平均分
        double Z1 = 0, Z2 = 0, Z3 = 0;//计算每门课标准差
        double Y1 = 0, Y2 = 0, Y3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <C1.length; i++) {
            he += C1[i];
        }
        X1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + X1);
        double Sum = 0;
        for (int i = 0; i < C2.length; i++) {
            Sum += C2[i];
        }
        X2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + X2);
        double sum = 0;
        for (int i = 0; i < C3.length; i++) {
            sum += C3[i];
        }
        X3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + X3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < C1.length; i++) {
            c1 += (C1[i] - X1) * (C1[i] - X1);
        }
        Z1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + Z1);
        for (int i = 0; i < C2.length; i++) {
            c2 += (C2[i] - X2) * (C2[i] - X2);
        }
        Z2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + Z2);

        for (int i = 0; i < C3.length; i++) {
            c3 += (C3[i] - X3) * (C3[i] - X3);
        }
        Z3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + Z3);
//


//        Arrays.sort(C1);
//        Arrays.sort(C2);
//        Arrays.sort(C3);
//        Y1 = (C1[14] + C2[15]) * 1.0 / 2;
//        Y2 = (C2[14] + C2[15]) * 1.0 / 2;
//        Y3 = (C3[14] + C3[15]) * 1.0 / 2;
//        System.out.println("生物化学的中位数为:" + Y1);
//        System.out.println("物理化学的中位数为:" + Y2);
//        System.out.println("电子与电工技术的中位数为:" + Y3);
    }

}
